home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / tools / qmake.com / QMAKE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1988-07-02  |  4.1 KB  |  87 lines

  1. /*  QMAKE       A program to expedite program maintenance using QEdit.
  2.  *              Jerry Houston - COLLEGE CORNER BBS - (206)643-0804
  3.  *
  4.  *              QMAKE strips the extension from the name of the file
  5.  *              that's currently being edited in QEdit, then runs MAKE
  6.  *              using that stripped file name.
  7.  *                  This allows easy program maintenance provided that
  8.  *              you insure that:
  9.  *
  10.  *                      ■  your macro for QEdit contains the
  11.  *                         path where your version of MAKE.EXE
  12.  *                         is stored (see USAGE below)
  13.  *                      ■  your makefile has the same name as
  14.  *                         the program being edited, but with
  15.  *                         no extension.
  16.  *
  17.  *  USAGE       From a command line, QMAKE could be run with the path to
  18.  *              MAKE.EXE and the name of the program being edited as
  19.  *              arguments, but it would be simpler to in that case just to
  20.  *              run MAKE with the appropriate filename.
  21.  *                  QMAKE should be invoked instead with a macro from within
  22.  *              QEdit.  An example of an appropriate macro is shown below.
  23.  *              Although the macro is here split into multiple lines for
  24.  *              readability, it should be one line in your QKEY.DEF file.
  25.  *              Be sure to run QCONFIG to reconfigure your copy of QEdit to
  26.  *              include the new macro, and put QMAKE into your DOS path.
  27.  *
  28.  *              <key to assign macro to> macro_begin save_file
  29.  *              dos 'QMAKE C:\BOUND\MAKE.EXE ' current_filename return
  30.  *                         |               |
  31.  *                        /                 \
  32.  *                       path to your MAKE.EXE
  33.  *
  34.  *              I assigned my macro to <Alt-K>, which is somewhat nmemonic
  35.  *              for maKe, and is not used in the default keybindings.  To
  36.  *              do the same, replace <key to assign macro to> in the above
  37.  *              description to  @k  .
  38.  *
  39.  *  ERRORS      None are returned from Qmake.
  40.  *
  41.  *  NOTES       Other such such programs exist, though the ones I've seen
  42.  *              don't work with MAKE.  They execute compiler commands
  43.  *              directly, based on the extension of the file being edited.
  44.  *                  Since I create a makefile for nearly every program I
  45.  *              compile, I find it easier just to run MAKE.EXE with the name
  46.  *              of the current file as an argument, stripped of its ext.
  47.  *                  Also, I usually don't care to have a file of errors
  48.  *              read into the editor as a separate file in another window.
  49.  *              usually it's sufficient just to note any errors before
  50.  *              returning to QEdit.  On the rare occasion that I want to
  51.  *              create a list of errors, I can do it from within the
  52.  *              makefile, and read it into QEdit with ordinary edit commands.
  53.  *                  This program QMAKE.EXE and the accompanying source are
  54.  *              placed into the public domain as of July 2, 1988, by the
  55.  *              author, Jerry Houston.  Enjoy!
  56.  */
  57. #include <STDIO.H>
  58. #include <PROCESS.H>
  59. #include <STRING.H>
  60. void main(int,char**, char**);
  61.  
  62.  
  63. void main(int argc, char **argv, char **envp)
  64. {
  65.     char *pcMarker;                 /* pointer to end of makefile name  */
  66.  
  67. /*  Point to the beginning of the filename argument.  If it contains a dot,
  68.  *  traverse to the dot, and replace it with a null.  Don't do this
  69.  *  truncation if the filename has no dot in it - it might be a makefile.
  70.  */
  71.     pcMarker = argv[2];
  72.     if( strchr( argv[2], '.' ))
  73.     {
  74.         while( *(++pcMarker) != '.' )      /* traverse filename to dot  */
  75.             ;
  76.         *pcMarker = '\0';           /* truncate filename extension      */
  77.     }
  78.  
  79. /*  Execute MAKE with a list of arguments:  argv[0] and argv[1].  Also
  80.  *  pass along the environment from here, so MAKE has access to PATH for
  81.  *  running the various compiler executables and the linker.
  82.  */
  83.     execle( argv[1], argv[1], argv[2], NULL, envp );
  84. }
  85.  
  86.  
  87.